<template>
	<view class="coverF flex-c">
		<stop isBack>
			<view slot="content">设备信息</view>
		</stop>
		<view class="flex-r flex-start flex-fill flex1 bcf bdtso">
			<view class="w20 bdrso bc13 fs8 c11 lh2">
				<view class="padtb2 padl1 bdbso bdw3 pos-r" @tap="tabCur(index)" :class="cur == index?'bcf bdc1':'bdc13'" 
				v-for="(item,index) in tabs" :key="index">
					<view>{{item}}</view>
					<ripple></ripple>
				</view>

			</view>
			<view class="flex1 pad2" style="overflow-y: auto;">
				<view class="" v-show="cur === 0">
					<view>
						<view class="list-style-2">设备图片</view>
						<view class="mart2">
							<image :src="pic(machine.pic)" mode="widthFix"></image>
						</view>
					</view>
					<view class="mart3 lh2">
						<view class="list-style-2 lh15">基础信息</view>
						<view class="flrc bdbda pad2">
							<view>名称：</view>
							<view class="flex1 tar">{{machine.name}}</view>
						</view>
						<view class="flrc bdbda pad2">
							<view>编号：</view>
							<view class="flex1 tar">{{machine.code}}</view>
							<view class="cu-btn sm line-blue round marl2" @tap="copy(machine.code)">复制</view>
						</view>
						<view class="flrc bdbda pad2">
							<view>型号：</view>
							<view class="flex1 tar">{{machine.sn}}</view>
						</view>
						<view class="flrc bdbda pad2">
							<view>使用状态：</view>
							<view class="flex1 tar">
								<view style="display: inline-block;">
									<status class="padlr2 round2" :item="machine.status"></status>
								</view>
							</view>
						</view>
						<view class="flrc bdbda pad2">
							<view>设备分组：</view>
							<view class="flex1 tar">{{isnull(machine.groups)?'':machine.groups.name}}</view>
						</view>
						<view class="flrc bdbda pad2">
							<view>设备标记：</view>
							<view class="flex1 tar">{{isnull(machine.mark)?'':machine.mark.name}}</view>
						</view>
						<view class="flrc bdbda pad2">
							<view>设备类型：</view>
							<view class="flex1 tar">{{isnull(machine.category)?'':machine.category.name}}</view>
						</view>

						<view class="flrc bdbda pad2">
							<view>购买时间：</view>
							<view class="flex1 tar">{{datetime(machine.buyAt)}}</view>
						</view>
						<view class="flrc bdbda pad2">
							<view>验收时间：</view>
							<view class="flex1 tar">{{datetime(machine.confirmAt)}}</view>
						</view>
						<view class="flrc bdbda pad2">
							<view>报废日期：</view>
							<view class="flex1 tar">{{datetime(machine.expireAt)}}</view>
						</view>
						<view class="flrc bdbda pad2">
							<view>使用寿命：</view>
							<view class="flex1 tar">{{machine.expireDays}} 天</view>
						</view>

						<view class="flrc bdbda pad2">
							<view>资产净值：</view>
							<view class="flex1 tar">{{machine.priceCurrent}}</view>
						</view>
						<view class="flrc bdbda pad2">
							<view>资产原值：</view>
							<view class="flex1 tar">{{machine.priceOrigin}}</view>
						</view>

					</view>
				</view>
				<view class="" v-show="cur === 1">
					<view class="lh2">
						<view class="flrc bdbda pad2">
							<view>所属部门：</view>
							<view class="flex1 tar">{{isnull(machine.department)?'':machine.department.name}}</view>
						</view>
						<view class="flrc bdbda pad2">
							<view>维修班组：</view>
							<view class="flex1 tar">{{isnull(machine.repairBy)?'':machine.repairBy.name}}</view>
						</view>
						<view class="flrc bdbda pad2 pos-r" @tap="goto('/pages/machine/user',$event)"
							:data-id="isnull(machine.operator)?0:machine.operator.id">
							<view>操作人：</view>
							<view class="flex1 tar">{{isnull(machine.operator)?'':machine.operator.name}}</view>
							<view class="fa fa-angle-right marl2"></view>
							<ripple></ripple>
						</view>
						
						<view class="flrc bdbda pad2 pos-r" @click="goto('/pages/machine/supplier',$event)"
							:data-id="isnull(machine.supplier)?0:machine.supplier.id">
							<view>供应商：</view>
							<view class="flex1 tar">{{isnull(machine.supplier)?'':machine.supplier.name}}</view>
							<view class="fa fa-angle-right marl2"></view>
							<ripple></ripple>
						</view>
						<view class="flrc bdbda pad2 pos-r" @click="goto('/pages/machine/agent',$event)"
							:data-id="isnull(machine.agent)?0:machine.agent.id">
							<view>代理商：</view>
							<view class="flex1 tar">{{isnull(machine.agent)?'':machine.agent.name}}</view>
							<view class="fa fa-angle-right marl2"></view>
							<ripple></ripple>
						</view>

					</view>
				</view>
				<!-- 点检标准 -->
				<view class="lh2" v-show="cur === 2">
					<view class="pad2 bc13 mar2" v-for="item in machine.checkPoints">
						<view class="flrc">
							<text class="fa fa-caret-right"></text>
							 <text class="pad1">点检项目：</text>
							<view class="flex1 fwb">{{item.name}}</view>
						</view>
						<!-- <view class="list-style-2">说明</view> -->
						<view><text class="fa fa-caret-right"></text> <text class="pad1">项目说明：</text>{{item.info}}</view>
						<view><text class="fa fa-caret-right"></text> <text class="pad1">操作选项：</text></view>
						<!-- <view class="list-style-2">操作选项</view> -->
						<view class="flex-r flex-start flex-wrap">
							<view class="cu-btn line-blue mar1 sm" v-for="choice in item.choices">{{choice}}</view>
						</view>
						<view><text class="fa fa-caret-right"></text> <text class="pad1">附加说明：</text></view>
						<view v-if="isnull(item.pics) || item.pics.length==0">无</view>
						<!-- {{item.pics.length}} -->
						<view>
							<image :src="pic(intro)" @tap="viewPic(pic(intro),pics(item.pics))" mode="widthFix" class="w100" v-for="intro in item.pics"></image>
						</view>
					</view>
				</view>
				<!-- 保养标准 -->
				
				<view class="lh2" v-show="cur === 3">
					<view class="pad2 bc13 mar2" v-for="item in machine.maintainPoints">
						<view class="flrc">
							<text class="fa fa-caret-right"></text>
							 <text class="pad1">点检项目：</text>
							<view class="flex1 fwb">{{item.name}}</view>
						</view>
						<!-- <view class="list-style-2">说明</view> -->
						<view><text class="fa fa-caret-right"></text> <text class="pad1">项目说明：</text>{{item.info}}</view>
						<view><text class="fa fa-caret-right"></text> <text class="pad1">操作选项：</text></view>
						<!-- <view class="list-style-2">操作选项</view> -->
						<view class="flex-r flex-start flex-wrap">
							<view class="cu-btn line-blue mar1 sm" v-for="choice in item.choices">{{choice}}</view>
						</view>
						<view><text class="fa fa-caret-right"></text> <text class="pad1">附加说明：</text></view>
						<view v-if="isnull(item.pics)">无</view>
						<view>
							<image :src="pic(intro)" @tap="viewPic(pic(intro),pics(item.pics))" mode="widthFix" class="w100" v-for="intro in item.pics"></image>
						</view>
					</view>
				</view>
				<!-- 相关记录 -->
				<view class="lh15" v-show="cur === 4">
					<view>
						<view class="list-style-1">相关记录</view>
						<view class="flrc pos-r bdbda bdtso mart3" @tap="goto('/pages/machine/info/machine_break_log?id=' + id)">
							<view class="flex1 pad2">维修记录</view>
							<view class="fa fa-angle-right"></view>
							<ripple></ripple>
						</view>
						<view class="flrc pos-r bdbda" @tap="goto('/pages/machine/info/machine_maintain_log?id=' + id)">
							<view class="flex1 pad2">保养记录</view>
							<view class="fa fa-angle-right"></view>
							<ripple></ripple>
						</view>
						<view class="flrc pos-r bdbda" @tap="goto('/pages/machine/info/machine_check_log?id=' + id)">
							<view class="flex1 pad2">点检记录</view>
							<view class="fa fa-angle-right"></view>
							<ripple></ripple>
						</view>
					</view>
					<view class="mart5">
						<view class="list-style-1">相关计划</view>
						<view class="flrc pos-r bdbda bdtso mart3" @tap="goto('/pages/machine/info/machine_maintain_plan?id=' + id)">
							<view class="flex1 pad2">保养计划</view>
							<view class="fa fa-angle-right"></view>
							<ripple></ripple>
						</view>
						<view class="flrc pos-r bdbda" @tap="goto('/pages/machine/info/machine_check_plan?id=' + id)">
							<view class="flex1 pad2">点检计划</view>
							<view class="fa fa-angle-right"></view>
							<ripple></ripple>
						</view>
					</view>
				</view>
			</view>
		</view>
		<loading :loading="myIsLoading"></loading>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				cur: 0,
				tabs: ["基本信息", "操作人","点检标准","保养标准","记录查询"],
				id: 0,
				machine: {},
			}
		},
		methods: {
			tabCur(index) {
				if(index >= 2){
					//获取维修记录
					switch(index){
						case 20://维修记录
							this.goto('/pages/machine/info/machine_break_log?id=' + this.id)
						break
						case 30://保养记录
							this.goto('/pages/machine/info/machine_maintain_log?id=' + this.id)
						break
						case 40://点检记录
							this.goto('/pages/machine/info/machine_check_log?id=' + this.id)
						break
						default:
						this.cur = index
					}
				}else{
					this.cur = index
				}
			}
		},
		onLoad(option) {
			this.id = option.id
			this.$api.get("/api/machines/" + this.id, {}, (res) => {
				this.clearLoading()
				this.machine = res.d
			})
		}
	}
</script>

<style>

</style>
